<script setup>
import { ref, watch } from 'vue'
import { usePopStore } from '@/stores'
import { storeToRefs } from 'pinia'
const popStore = usePopStore()
const { Radar, XY } = storeToRefs(popStore)
const close = () => {
  Radar.value.showPop = false
}
const dialogPosition = ref([0, 0])
watch(
  Radar.value,
  (newVal) => {
    if (newVal) {
      dialogPosition.value = XY.value
    }
  },
  {
    deep: true
  }
)
</script>
<template>
  <transition
    appear
    name="custom-classes-transition"
    enter-active-class="animate__animated  animate__fadeIn"
    leave-active-class="animate__animated animate__faster  animate__fadeOut"
  >
    <!-- <div
      class="AirspacePop"
      ref="currentDom"
      :style="{
        left: dialogPosition[0] + 'px',
        top: dialogPosition[1] + 'px'
      }"
      v-if="RiseLand.showPop"
    > -->
    <div
      class="AirspacePop"
      ref="currentDom"
      :style="{
        left: dialogPosition[0] + 'px',
        top: dialogPosition[1] + 'px'
      }"
      v-if="Radar.showPop"
      v-drag
    >
      <p class="title">
        <span>飞行物信息</span>
        <span @click="close"><img src="@img/pop/close_icon.png" alt="" /></span>
      </p>
      <div class="content">
        <div class="left">
          <p>
            <span>· <i>类型</i> ：</span>
            <span>{{ Radar.popInfo.type }}</span>
          </p>
          <p>
            <span>· <i>高度</i> ：</span>
            <span>{{ Radar.popInfo.height }}</span>
          </p>
          <p>
            <span>· <i>速度</i> ：</span>
            <span>{{ Radar.popInfo.speed }}</span>
          </p>
          <p>
            <span>· <i>方向</i> ：</span>
            <span>{{ Radar.popInfo.direction }}</span>
          </p>
        </div>
      </div>
    </div>
  </transition>
</template>
<style scoped lang="scss">
.AirspacePop {
  position: fixed;
  z-index: 9;
  top: 50%;
  left: 50%;
  width: 300px;
  height: 200px;
  background: url('@img/pop/airspace_bg.png');
  background-size: 100% 100%;

  .title {
    display: flex;
    padding: 10px 20px 10px 50px;
    align-items: center;
    font-size: 16px;
    justify-content: space-between;

    span:last-child {
      width: 18px;
      height: 18px;
      cursor: pointer;

      img {
        width: 100%;
        height: 100%;
      }
    }
  }

  .content {
    margin-top: 5px;
    padding: 12px;
    display: flex;
    font-size: 13px;

    .left {
      flex: 1;

      p {
        display: flex;
        margin-bottom: 10px;

        span:first-child {
          flex: 0 0 80px;
          color: #afebff;
          display: flex;
          align-items: center;
          i {
            display: inline-block;
            width: 100%;
            margin: 0 3px;
            text-align-last: justify;
            text-align: justify;
            font-style: normal;
          }
        }

        span:last-child {
          flex: 1;
          white-space: nowrap;
          overflow: hidden;
          text-overflow: ellipsis;
          margin-left: 10px;
        }

        &.name {
          font-size: 14px;
        }
      }
    }
  }
}
</style>
